package com.giveu.signature.config;

import java.util.HashMap;
import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import com.giveu.common.utils.security.MD5;
import com.google.common.base.Joiner;

import lombok.Data;
/**   
 * @ClassName:  AppProperties   
 * @Description:TODO(这里用一句话描述这个类的作用)   
 * @author: 538513 
 * @date:   2018年10月17日 下午5:24:18   
 *     
 */  
/**   
 * @ClassName:  AppProperties   
 * @Description:TODO(这里用一句话描述这个类的作用)   
 * @author: 538513 
 * @date:   2018年10月17日 下午5:24:20   
 *     
 */  
@RefreshScope
@Component
@ConfigurationProperties(prefix = "spring.cloud.feign")
@Data
public class FeignProperties {
	
	/**
	 * fast
	 */
	private Map<String, String> fastdfsClient;
	/**
	 * 签字系统
	 */
	private Map<String, String> signature;
	/**
	 * 代扣放款
	 */
	private Map<String, String> withholdLoan;
	/**
	 * 代扣还款
	 */
	private Map<String, String> withholdRepayment;
	/**
	 * 征信平台
	 */
	private Map<String, String> creditReport;
	
	
	public String getFastdfsUrl() {
		return fastdfsClient.get(AppConsts.URL)+"/";
	}
	
	public String getFastdfsSign() {
		String fastDfsId = fastdfsClient.get(AppConsts.SERVICE_ID);
		String fastDfsKey = fastdfsClient.get(AppConsts.KEY);
		Map<String, Object> map = new HashMap<>(16);
		map.put("service_id", fastDfsId);
		map.put("md5_key", fastDfsKey);
		String str = Joiner.on("&").withKeyValueSeparator("=").join(map);
		return MD5.md5(str);
	}
	
}
